package com.yuhan.business.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yuhan.common.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Past;
import java.util.Date;

@Data
@Entity
@DynamicUpdate
@DynamicInsert
@Table(name = "cr_user")
@Where(clause = " del_flag = 0 ")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "fieldHandler"})
public class User extends BaseEntity {

    @ApiModelProperty("所属机构")
    @Column(name = "deptId")
    private String deptId;

    @ApiModelProperty("登录名")
    @Column(name = "loginname")
    @NotBlank(message = "登陆名不能为空")
    private String loginname;

    @ApiModelProperty("用户名")
    @Column(name = "username")
    private String username;

    @ApiModelProperty("证件类型1:身份证号2:军官证号")
    @Column(name = "card_type", columnDefinition = "1")
    private String cardType;

    @ApiModelProperty("证件号")
    @Column(name = "idcard")
    private String idcard;

    @ApiModelProperty("证件有效期")
    @Column(name = "card_data")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Past
    private Date cardData;

    @ApiModelProperty("邮箱")
    @Column(name = "email")
    @Email(message = "请输入正确的邮箱格式")
    @NotEmpty(message = "邮箱不能为空")
    private String email;

    @ApiModelProperty("手机号")
    @Column(name = "mobile")
    private String mobile;

    @ApiModelProperty("状态 0:禁用，1:正常")
    @Column(name = "enabled", columnDefinition = "1")
    private String enabled;

    @ApiModelProperty("备注")
    @Column(name = "remark")
    private String remark;

    @ApiModelProperty("性别 0:男，1:女")
    @Column(name = "sex")
    private String sex;

    @ApiModelProperty("地址")
    @Column(name = "address")
    private String address;

    @ApiModelProperty("职业类型")
    @Column(name = "position_type")
    private String positionType;

    @ApiModelProperty("1:注册账号，2:后台管理账号")
    @Column(name = "type")
    private String type;

    @ApiModelProperty("是否认证1：是2否")
    @Column(name = "authentication", columnDefinition = "2")
    private Integer authentication;

    @ApiModelProperty("审批状态")
    @Column(name = "approve_status", columnDefinition = "0")
    private String approvalStatus;

    @ApiModelProperty("审批意见")
    @Column(name = "approve_msg")
    private String approvalMsg;

}
